/*************************************************************************
	> File Name: handle.h
	> Author: ma6174
	> Mail: ma6174@163.com 
	> Created Time: 2021年12月09日 星期四 20时57分24秒
 ************************************************************************/

#include<iostream>
#include <string>

//Request类
class Request
{
public:
	Request() = default;
	Request(std::string rt, std::string rc, int n) : requestType(rt), requestContent(rc), number(n) {}

	std::string getRequestType()
	{
		return requestType;
	}

	void setRequestType(std::string rt)
	{
		requestType = rt;
	}

	std::string getRequestContent()
	{
		return requestContent;
	}

	void setRequestContent(std::string rc)
	{
		requestContent = rc;
	}

	int getNumber()
	{
		return number;
	}

	void setNumber(int n)
	{
		number = n;
	}

private:
	std::string requestType;
	std::string requestContent;
	int number;
};

//管理抽象类
class Manager
{
public:
	Manager() = default;
	Manager(std::string m) : name(m) {}

	void setSuperior(Manager* sr)
	{
		superior = sr;
	}

	virtual void requestApplication(Request request) = 0;

protected:
	std::string name;
	Manager* superior;
};

//管理者具体类
//经理
class CommonManager : public Manager
{
public:
	using Manager::Manager;
	virtual void requestApplication(Request request)
	{
		if (request.getRequestType() == "请假" && request.getNumber() <= 2)
			std::cout << name << "\t:\t" << request.getRequestContent() << "\t数量:\t" << request.getNumber() << 
				"\t被批准" << std::endl;
		else
			if (superior != nullptr)
				superior->requestApplication(request);
	}
};

//总监
class Majordomo : public Manager
{
public:
	using Manager::Manager;
	virtual void requestApplication(Request request)
	{
		if (request.getRequestType() == "请假" && request.getNumber() <= 5)
			std::cout << name << "\t:\t" << request.getRequestContent() << "\t数量:\t" << request.getNumber() << 
				"\t被批准" << std::endl;
		else
			if (superior != nullptr)
				superior->requestApplication(request);
	}
};

//总经理
class GeneralManager : public Manager
{
public:
	using Manager::Manager;
	virtual void requestApplication(Request request)
	{
		if (request.getRequestType() == "请假")
			std::cout << name << "\t:\t" << request.getRequestContent() << "\t数量:\t" << request.getNumber() << 
				"\t被批准" << std::endl;
		else if (request.getRequestType() == "加薪" && request.getNumber() <= 500)
			std::cout << name << "\t:\t" << request.getRequestContent() << "\t数量:\t" << request.getNumber() << 
				"\t被批准" << std::endl;
		else if (request.getRequestType() == "加薪" && request.getNumber() > 500)
			std::cout << name << "\t:\t" << request.getRequestContent() << "\t数量:\t" << request.getNumber() << 
				"\t再说吧" << std::endl;
	}
};
